package org.huangrui.junit;

import org.junit.jupiter.api.*;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @auther hr
 * @create 2025-11-02 17:03
 */
class T01CalcTestV2 {
    T01Calc calc = null;

    static StringBuffer stringBuffer = null;

    @BeforeAll
    static void m1() {
        stringBuffer = new StringBuffer("abc");
        System.out.println("===============: " + stringBuffer.length());
    }

    @AfterAll
    static void m2() {
        System.out.println("===============: " + stringBuffer.append(" ,end").toString());
    }


    @BeforeEach
    void setUp() {
        System.out.println("----come in BeforeEach");
        calc = new T01Calc();
    }

    @AfterEach
    void tearDown() {
        System.out.println("----come in AfterEach");
        calc = null;
    }

    @Test
    void add() {
        assertEquals(5, calc.add(1, 4));
        assertEquals(5, calc.add(2, 3));
    }

    @Test
    void sub() {
        assertEquals(5, calc.sub(10, 5));
    }
}